; Disassembly of the file "Z:\home\knoppix\Public\LOADER1.COM"
; 
; CPU Type: Z80
; 
; Using the opcode map file "Z:\home\knoppix\Public\LOADER1.COM.opmap"
; ; Created with dZ80 2.0
; 
; on Thursday, 09 of February 2017 at 11:07 AM
; 
0100 C30C01	JP	$010C

0103 00		DEFW	$0000		; CODE LOAD ADDR ($4000 or $5B00)
0105 00		DEFW	$0000		; CODE LENGTH ($C000 or $A500)
0107 00		DEFW	$0000		; START ADDR IN BASIC
0109 00		DEFW	$0000		; STACK POINTER VALUE AT NMI
010B 00		DEFB	$00

010C F3		DI	
010D ED4B0501	LD	BC,($0105)	; BC = CODE LENGTH
0111 2A0301	LD	HL,($0103)	; HL = CODE LOAD ADDR
0114 09		ADD	HL,BC		; HL = CODE END ADDR
0115 EB		EX	DE,HL		; DE = CODE END ADDR
0116 210003	LD	HL,$0300	; HL = CODE START ADDR as loaded in CP/M
0119 09		ADD	HL,BC		; HL = CODE END ADDR as loaded in CP/M
011A 03		INC	BC		; BC = CODE LENGTH + 1
011B EDB8	LDDR			; Translate code block to its Basic run address
011D 3E3F	LD	A,$3F		; test value for code load start
011F BA		CP	D		; if code load start was $4000, DE = $3FFF
0120 2020	JR	NZ,$0142	; skip ahead if code doesn't include screen
0122 01011B	LD	BC,$1B01	; BC = video mem size + 1
0125 EB		EX	DE,HL		; HL = code load start addr - 1 = last video mem byte (if code includes screen)
0126 3E41	LD	A,$41		; <--- <--- <--- <--- <--- <--- <--- <--- <--- <--- <--- <----|
0128 5E		LD	E,(HL)		; read last video mem byte from code			      |
0129 D3FE	OUT	($FE),A		; set 06=1 for VRAM access, border blue			      |
012B 73		LD	(HL),E		; write last video mem byte to CP/M video mem		      |
012C EE40	XOR	$40		; A = $41 xor $40 = $01					      |
012E D3FE	OUT	($FE),A		; set 06=0 for DRAM#1 access, border blue		      |
0130 23		INC	HL		; HL = code load start addr				      |
0131 0B		DEC	BC		; BC = video mem size					      |
0132 78		LD	A,B		;							      |
0133 B1		OR	C		; test if BC = $0000					      |
0134 C22601	JP	NZ,$0126	; if not, repeat loop and load game screen ---> ---> ---> --->|
0137 01FE00	LD	BC,$00FE	; C = 8255 port A addr <--- <--- <--- <--|
013A ED78	IN	A,(C)		; read keyboard ...			 |
013C E61F	AND	$1F		; ... without F1-F4 and ESC-CTRL	 |
013E FE1F	CP	$1F		; check if any key pressed		 |
0140 28F5	JR	Z,$0137		; if not, repeat loop ---> ---> ---> --->|
0142 3A0B01	LD	A,($010B)	; A = $00
0145 B7		OR	A		; test ($010B)
0146 2810	JR	Z,$0158		; if zero skip ahead ---> ---> ---> --->|
0148 ED5F	LD	A,R
014A 327802	LD	($0278),A	; save R to ($0278)  ??!!??
014D 11005C	LD	DE,$5C00
0150 210002	LD	HL,$0200
0153 01FB00	LD	BC,$00FB
0156 EDB0	LDIR			; copy $00FB bytes from $0200 to $5C00  ??!!??
0158 3E3F	LD	A,$3F		;
015A ED47	LD	I,A		; assume I was $3F at NMI (stupid assumption)
015C ED56	IM	1		; assume IM was 1 at NMI (stupid assumption)
015E FD213A5C	LD	IY,$5C3A	; assume IY was $5C3A at NMI (stupid assumption)
0162 ED7B0901	LD	SP,($0109)	; SP = stack pointer value at NMI
0166 2A0701	LD	HL,($0107)	; HL = start addr in BASIC
0169 D9		EXX
016A 213800	LD	HL,$0038	; addr of BASIC loading routine in BOOT ROM
016D 3E03	LD	A,$03
016F D3FB	OUT	($FB),A		; disable
0171 D3F3	OUT	($F3),A		; interrupts
0173 D3EB	OUT	($EB),A		; from
0175 D3E3	OUT	($E3),A		; Z80-CTC
0177 AF		XOR	A
0178 D3F5	OUT	($F5),A		; OUT to 8272 Status Register !!!! Idiot who wrote this tried to OUT to an 8272 INPUT port
					; This should be OUT ($FD),A, to set 8272 to standby
017A 3E00	LD	A,$00		; <-- USELESS, CAN BE DELETED
017C D3FE	OUT	($FE),A		; set SO=0 which selects OPUS (wrong!!), 06=0 (wrong!!, should be 1 for BOOT config), border black
017E 3E80	LD	A,$80
0180 ED4F	LD	R,A		; set bit 7 of R to 1 for startup hw config
0182 E9		JP	(HL)		; after changing to BOOT hw config (WHICH NEVER HAPPENS!), jump to 0038h

					; ######### END OF A (USELESS) CODE WRITTEN BY A TOTAL IDIOT ##########

0183 00		DEFB	$00
0184 00		DEFB	$00
0185 00		DEFB	$00
0186 00		DEFB	$00
0187 00		DEFB	$00
0188 00		DEFB	$00
0189 00		DEFB	$00
018A 00		DEFB	$00
018B 00		DEFB	$00
018C 00		DEFB	$00
018D 00		DEFB	$00
018E 00		DEFB	$00
018F 00		DEFB	$00
0190 00		DEFB	$00
0191 00		DEFB	$00
0192 00		DEFB	$00
0193 00		DEFB	$00
0194 00		DEFB	$00
0195 00		DEFB	$00
0196 00		DEFB	$00
0197 00		DEFB	$00
0198 00		DEFB	$00
0199 00		DEFB	$00
019A 00		DEFB	$00
019B 00		DEFB	$00
019C 00		DEFB	$00
019D 00		DEFB	$00
019E 00		DEFB	$00
019F 00		DEFB	$00
01A0 00		DEFB	$00
01A1 00		DEFB	$00
01A2 00		DEFB	$00
01A3 00		DEFB	$00
01A4 00		DEFB	$00
01A5 00		DEFB	$00
01A6 00		DEFB	$00
01A7 00		DEFB	$00
01A8 00		DEFB	$00
01A9 00		DEFB	$00
01AA 00		DEFB	$00
01AB 00		DEFB	$00
01AC 00		DEFB	$00
01AD 00		DEFB	$00
01AE 00		DEFB	$00
01AF 00		DEFB	$00
01B0 00		DEFB	$00
01B1 00		DEFB	$00
01B2 00		DEFB	$00
01B3 00		DEFB	$00
01B4 00		DEFB	$00
01B5 00		DEFB	$00
01B6 00		DEFB	$00
01B7 00		DEFB	$00
01B8 00		DEFB	$00
01B9 00		DEFB	$00
01BA 00		DEFB	$00
01BB 00		DEFB	$00
01BC 00		DEFB	$00
01BD 00		DEFB	$00
01BE 00		DEFB	$00
01BF 00		DEFB	$00
01C0 00		DEFB	$00
01C1 00		DEFB	$00
01C2 00		DEFB	$00
01C3 00		DEFB	$00
01C4 00		DEFB	$00
01C5 00		DEFB	$00
01C6 00		DEFB	$00
01C7 00		DEFB	$00
01C8 00		DEFB	$00
01C9 00		DEFB	$00
01CA 00		DEFB	$00
01CB 00		DEFB	$00
01CC 00		DEFB	$00
01CD 00		DEFB	$00
01CE 00		DEFB	$00
01CF 00		DEFB	$00
01D0 00		DEFB	$00
01D1 00		DEFB	$00
01D2 00		DEFB	$00
01D3 00		DEFB	$00
01D4 00		DEFB	$00
01D5 00		DEFB	$00
01D6 00		DEFB	$00
01D7 00		DEFB	$00
01D8 00		DEFB	$00
01D9 00		DEFB	$00
01DA 00		DEFB	$00
01DB 00		DEFB	$00
01DC 00		DEFB	$00
01DD 00		DEFB	$00
01DE 00		DEFB	$00
01DF 00		DEFB	$00
01E0 00		DEFB	$00
01E1 00		DEFB	$00
01E2 00		DEFB	$00
01E3 00		DEFB	$00
01E4 00		DEFB	$00
01E5 00		DEFB	$00
01E6 00		DEFB	$00
01E7 00		DEFB	$00
01E8 00		DEFB	$00
01E9 00		DEFB	$00
01EA 00		DEFB	$00
01EB 00		DEFB	$00
01EC 00		DEFB	$00
01ED 00		DEFB	$00
01EE 00		DEFB	$00
01EF 00		DEFB	$00
01F0 00		DEFB	$00
01F1 00		DEFB	$00
01F2 00		DEFB	$00
01F3 00		DEFB	$00
01F4 00		DEFB	$00
01F5 00		DEFB	$00
01F6 00		DEFB	$00
01F7 00		DEFB	$00
01F8 00		DEFB	$00
01F9 00		DEFB	$00
01FA 00		DEFB	$00
01FB 00		DEFB	$00
01FC 00		DEFB	$00
01FD 00		DEFB	$00
01FE 00		DEFB	$00
01FF 00		DEFB	$00